package com.ruoyi.buss.active.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.active.domain.DataKhhdImport;
import com.ruoyi.buss.active.service.IDataKhhdImportService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 客户活动Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/active")
public class DataKhhdImportController extends BaseController
{
    @Autowired
    private IDataKhhdImportService dataKhhdImportService;

    /**
     * 查询客户活动列表
     */
    @PreAuthorize(hasPermi = "buss:active:list")
    @GetMapping("/list")
    public TableDataInfo list(DataKhhdImport dataKhhdImport)
    {
        startPage();
        List<DataKhhdImport> list = dataKhhdImportService.selectDataKhhdImportList(dataKhhdImport);
        return getDataTable(list);
    }

    /**
     * 导出客户活动列表
     */
    @PreAuthorize(hasPermi = "buss:active:export")
    @Log(title = "客户活动", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataKhhdImport dataKhhdImport) throws IOException
    {
        List<DataKhhdImport> list = dataKhhdImportService.selectDataKhhdImportList(dataKhhdImport);
        ExcelUtil<DataKhhdImport> util = new ExcelUtil<DataKhhdImport>(DataKhhdImport.class);
        util.exportExcel(response, list, "客户活动数据");
    }

    /**
     * 获取客户活动详细信息
     */
    @PreAuthorize(hasPermi = "buss:active:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(dataKhhdImportService.selectDataKhhdImportById(id));
    }

    /**
     * 新增客户活动
     */
    @PreAuthorize(hasPermi = "buss:active:add")
    @Log(title = "客户活动", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataKhhdImport dataKhhdImport)
    {
        return toAjax(dataKhhdImportService.insertDataKhhdImport(dataKhhdImport));
    }

    /**
     * 修改客户活动
     */
    @PreAuthorize(hasPermi = "buss:active:edit")
    @Log(title = "客户活动", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataKhhdImport dataKhhdImport)
    {
        return toAjax(dataKhhdImportService.updateDataKhhdImport(dataKhhdImport));
    }

    /**
     * 删除客户活动
     */
    @PreAuthorize(hasPermi = "buss:active:remove")
    @Log(title = "客户活动", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(dataKhhdImportService.deleteDataKhhdImportByIds(ids));
    }
}
